package cn.gift.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * @author ZhaoLc
 */
@Configuration
@EnableSwagger2
@EnableKnife4j
public class KnifejConfig {
    @Bean
    public Docket docket() {
        //指定使用Swagger2规范
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                //分组名称
                //.groupName("测试展示")
                .enable(true)
                .select()
                //指定扫描包的路径
                .apis(RequestHandlerSelectors.basePackage("cn.gift"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        //生成文档的一些基础信息
        return new ApiInfo("权限服务",
                "接口文档",
                "v1.0",
                "",
                new Contact("ZhaoLc", "http://Mall/test", "398333404@qq.com"),
                "Apache 2.0",
                "Http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList<>());
    }
}